<!DOCTYPE HTML>

<html lang="en">
<head>

<title>HpkpHeaderWriter (spring-security-docs 5.6.3 API)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../../../jquery/jquery-3.5.1.js"></script>
<script type="text/javascript" src="../../../../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
    try {
        if (location.href.indexOf('is-external=true') == -1) {
            parent.document.title="HpkpHeaderWriter (spring-security-docs 5.6.3 API)";
        }
    }
    catch(err) {
    }
//-->
var data = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
var pathtoroot = "../../../../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav">

<div class="topNav"><a id="navbar.top">

</a>
<div class="skipNav"><a href="HpkpHeaderWriter.html#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">

</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="HpkpHeaderWriter.html#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="HpkpHeaderWriter.html#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="HpkpHeaderWriter.html#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="HpkpHeaderWriter.html#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.top">

</a></div>

</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>

<main role="main">
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">org.springframework.security.web.header.writers</a></div>
<h2 title="Class HpkpHeaderWriter" class="title">Class HpkpHeaderWriter</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.springframework.security.web.header.writers.HpkpHeaderWriter</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><code><a href="../HeaderWriter.html" title="interface in org.springframework.security.web.header">HeaderWriter</a></code></dd>
</dl>
<hr>
<pre>public final class <span class="typeNameLabel">HpkpHeaderWriter</span>
extends java.lang.Object
implements <a href="../HeaderWriter.html" title="interface in org.springframework.security.web.header">HeaderWriter</a></pre>
<div class="block">Provides support for <a href="https://tools.ietf.org/html/rfc7469">HTTP Public Key
Pinning (HPKP)</a>.
<p>
Since <a href="https://tools.ietf.org/html/rfc7469#section-4.1">Section 4.1</a> states
that a value on the order of 60 days (5,184,000 seconds) may be considered a good
balance, we use this value as the default. This can be customized using
<a href="HpkpHeaderWriter.html#setMaxAgeInSeconds(long)"><code>setMaxAgeInSeconds(long)</code></a>.
</p>
<p>
Because <a href="https://tools.ietf.org/html/rfc7469#appendix-B">Appendix B</a>
recommends that operators should first deploy public key pinning by using the
report-only mode, we opted to use this mode as default. This can be customized using
<a href="HpkpHeaderWriter.html#setReportOnly(boolean)"><code>setReportOnly(boolean)</code></a>.
</p>
<p>
Since we need to validate a certificate chain, the "Public-Key-Pins" or
"Public-Key-Pins-Report-Only" header will only be added when
<code>ServletRequest.isSecure()</code> returns <code>true</code>.
</p>
<p>
To set the pins you first need to extract the public key information from your
certificate or key file and encode them using Base64. The following commands will help
you extract the Base64 encoded information from a key file, a certificate signing
request, or a certificate.
<pre> openssl rsa -in my-key-file.key -outform der -pubout | openssl dgst -sha256 -binary | openssl enc -base64

 openssl req -in my-signing-request.csr -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64

 openssl x509 -in my-certificate.crt -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
 </pre>
The following command will extract the Base64 encoded information for a website.
<pre> openssl s_client -servername www.example.com -connect www.example.com:443 | openssl x509 -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
 </pre>
</p>
<p>
Some examples:
<pre> Public-Key-Pins: max-age=3000;
                pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
                pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="

 Public-Key-Pins: max-age=5184000;
                pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
                pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ="

 Public-Key-Pins: max-age=5184000;
                pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
                pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
                report-uri="https://example.com/pkp-report"

 Public-Key-Pins-Report-Only: max-age=5184000;
                pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
                pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
                report-uri="https://other.example.net/pkp-report"

 Public-Key-Pins: max-age=5184000;
                pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
                pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
                pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
                includeSubDomains
 </pre>
</p></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>4.1</dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.summary">

</a>
<h3>Constructor Summary</h3>
<table class="memberSummary">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Constructor</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#%3Cinit%3E()">HpkpHeaderWriter</a></span>()</code></th>
<td class="colLast">
<div class="block">Creates a new instance</div>
</td>
</tr>
<tr class="rowColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#%3Cinit%3E(long)">HpkpHeaderWriter</a></span>&#8203;(long&nbsp;maxAgeInSeconds)</code></th>
<td class="colLast">
<div class="block">Creates a new instance</div>
</td>
</tr>
<tr class="altColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#%3Cinit%3E(long,boolean)">HpkpHeaderWriter</a></span>&#8203;(long&nbsp;maxAgeInSeconds,
boolean&nbsp;includeSubDomains)</code></th>
<td class="colLast">
<div class="block">Creates a new instance</div>
</td>
</tr>
<tr class="rowColor">
<th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#%3Cinit%3E(long,boolean,boolean)">HpkpHeaderWriter</a></span>&#8203;(long&nbsp;maxAgeInSeconds,
boolean&nbsp;includeSubDomains,
boolean&nbsp;reportOnly)</code></th>
<td class="colLast">
<div class="block">Creates a new instance</div>
</td>
</tr>
</table>
</li>
</ul>
</section>

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.summary">

</a>
<h3>Method Summary</h3>
<table class="memberSummary">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Method</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#addSha256Pins(java.lang.String...)">addSha256Pins</a></span>&#8203;(java.lang.String...&nbsp;pins)</code></th>
<td class="colLast">
<div class="block">
Adds a list of SHA256 hashed pins for the pin- directive of the Public-Key-Pins
header.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#setIncludeSubDomains(boolean)">setIncludeSubDomains</a></span>&#8203;(boolean&nbsp;includeSubDomains)</code></th>
<td class="colLast">
<div class="block">
If true, the pinning policy applies to this pinned host as well as any subdomains
of the host's domain name.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#setMaxAgeInSeconds(long)">setMaxAgeInSeconds</a></span>&#8203;(long&nbsp;maxAgeInSeconds)</code></th>
<td class="colLast">
<div class="block">
Sets the value (in seconds) for the max-age directive of the Public-Key-Pins
header.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#setPins(java.util.Map)">setPins</a></span>&#8203;(java.util.Map&lt;java.lang.String,&#8203;java.lang.String&gt;&nbsp;pins)</code></th>
<td class="colLast">
<div class="block">
Sets the value for the pin- directive of the Public-Key-Pins header.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#setReportOnly(boolean)">setReportOnly</a></span>&#8203;(boolean&nbsp;reportOnly)</code></th>
<td class="colLast">
<div class="block">
To get a Public-Key-Pins header you should set this to false, otherwise the header
will be Public-Key-Pins-Report-Only.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#setReportUri(java.lang.String)">setReportUri</a></span>&#8203;(java.lang.String&nbsp;reportUri)</code></th>
<td class="colLast">
<div class="block">
Sets the URI to which the browser should report pin validation failures.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#setReportUri(java.net.URI)">setReportUri</a></span>&#8203;(java.net.URI&nbsp;reportUri)</code></th>
<td class="colLast">
<div class="block">
Sets the URI to which the browser should report pin validation failures.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="HpkpHeaderWriter.html#writeHeaders(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)">writeHeaders</a></span>&#8203;(javax.servlet.http.HttpServletRequest&nbsp;request,
javax.servlet.http.HttpServletResponse&nbsp;response)</code></th>
<td class="colLast">
<div class="block">Create a <code>Header</code> instance.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a id="methods.inherited.from.class.java.lang.Object">

</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="constructor.detail">

</a>
<h3>Constructor Detail</h3>
<a id="&lt;init&gt;(long,boolean,boolean)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>HpkpHeaderWriter</h4>
<pre>public&nbsp;HpkpHeaderWriter&#8203;(long&nbsp;maxAgeInSeconds,
                        boolean&nbsp;includeSubDomains,
                        boolean&nbsp;reportOnly)</pre>
<div class="block">Creates a new instance</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>maxAgeInSeconds</code> - maps to <a href="HpkpHeaderWriter.html#setMaxAgeInSeconds(long)"><code>setMaxAgeInSeconds(long)</code></a></dd>
<dd><code>includeSubDomains</code> - maps to <a href="HpkpHeaderWriter.html#setIncludeSubDomains(boolean)"><code>setIncludeSubDomains(boolean)</code></a></dd>
<dd><code>reportOnly</code> - maps to <a href="HpkpHeaderWriter.html#setReportOnly(boolean)"><code>setReportOnly(boolean)</code></a></dd>
</dl>
</li>
</ul>
<a id="&lt;init&gt;(long,boolean)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>HpkpHeaderWriter</h4>
<pre>public&nbsp;HpkpHeaderWriter&#8203;(long&nbsp;maxAgeInSeconds,
                        boolean&nbsp;includeSubDomains)</pre>
<div class="block">Creates a new instance</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>maxAgeInSeconds</code> - maps to <a href="HpkpHeaderWriter.html#setMaxAgeInSeconds(long)"><code>setMaxAgeInSeconds(long)</code></a></dd>
<dd><code>includeSubDomains</code> - maps to <a href="HpkpHeaderWriter.html#setIncludeSubDomains(boolean)"><code>setIncludeSubDomains(boolean)</code></a></dd>
</dl>
</li>
</ul>
<a id="&lt;init&gt;(long)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>HpkpHeaderWriter</h4>
<pre>public&nbsp;HpkpHeaderWriter&#8203;(long&nbsp;maxAgeInSeconds)</pre>
<div class="block">Creates a new instance</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>maxAgeInSeconds</code> - maps to <a href="HpkpHeaderWriter.html#setMaxAgeInSeconds(long)"><code>setMaxAgeInSeconds(long)</code></a></dd>
</dl>
</li>
</ul>
<a id="&lt;init&gt;()">

</a>
<ul class="blockListLast">
<li class="blockList">
<h4>HpkpHeaderWriter</h4>
<pre>public&nbsp;HpkpHeaderWriter()</pre>
<div class="block">Creates a new instance</div>
</li>
</ul>
</li>
</ul>
</section>

<section role="region">
<ul class="blockList">
<li class="blockList"><a id="method.detail">

</a>
<h3>Method Detail</h3>
<a id="writeHeaders(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>writeHeaders</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;writeHeaders&#8203;(javax.servlet.http.HttpServletRequest&nbsp;request,
                         javax.servlet.http.HttpServletResponse&nbsp;response)</pre>
<div class="block"><span class="descfrmTypeLabel">Description copied from interface:&nbsp;<code><a href="../HeaderWriter.html#writeHeaders(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)">HeaderWriter</a></code></span></div>
<div class="block">Create a <code>Header</code> instance.</div>
<dl>
<dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
<dd><code><a href="../HeaderWriter.html#writeHeaders(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)">writeHeaders</a></code>&nbsp;in interface&nbsp;<code><a href="../HeaderWriter.html" title="interface in org.springframework.security.web.header">HeaderWriter</a></code></dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>request</code> - the request</dd>
<dd><code>response</code> - the response</dd>
</dl>
</li>
</ul>
<a id="setPins(java.util.Map)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>setPins</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;setPins&#8203;(java.util.Map&lt;java.lang.String,&#8203;java.lang.String&gt;&nbsp;pins)</pre>
<div class="block"><p>
Sets the value for the pin- directive of the Public-Key-Pins header.
</p>
<p>
The pin directive specifies a way for web host operators to indicate a
cryptographic identity that should be bound to a given web host. See
<a href="https://tools.ietf.org/html/rfc7469#section-2.1.1">Section 2.1.1</a> for
additional details.
</p>
<p>
To get a pin of
Public-Key-Pins: pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="
Use
<code>
Map&lt;String, String&gt; pins = new HashMap&lt;String, String&gt;();
pins.put("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=", "sha256");
pins.put("E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=", "sha256");
</code>
</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>pins</code> - the map of base64-encoded SPKI fingerprint &amp; cryptographic hash
algorithm pairs.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if pins is null</dd>
</dl>
</li>
</ul>
<a id="addSha256Pins(java.lang.String...)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>addSha256Pins</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;addSha256Pins&#8203;(java.lang.String...&nbsp;pins)</pre>
<div class="block"><p>
Adds a list of SHA256 hashed pins for the pin- directive of the Public-Key-Pins
header.
</p>
<p>
The pin directive specifies a way for web host operators to indicate a
cryptographic identity that should be bound to a given web host. See
<a href="https://tools.ietf.org/html/rfc7469#section-2.1.1">Section 2.1.1</a> for
additional details.
</p>
<p>
To get a pin of
Public-Key-Pins-Report-Only:
pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="
Use
HpkpHeaderWriter hpkpHeaderWriter = new HpkpHeaderWriter();
hpkpHeaderWriter.addSha256Pins("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM",
"E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=");
</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>pins</code> - a list of base64-encoded SPKI fingerprints.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if a pin is null</dd>
</dl>
</li>
</ul>
<a id="setMaxAgeInSeconds(long)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>setMaxAgeInSeconds</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;setMaxAgeInSeconds&#8203;(long&nbsp;maxAgeInSeconds)</pre>
<div class="block"><p>
Sets the value (in seconds) for the max-age directive of the Public-Key-Pins
header. The default is 60 days.
</p>
<p>
This instructs browsers how long they should regard the host (from whom the message
was received) as a known pinned host. See
<a href="https://tools.ietf.org/html/rfc7469#section-2.1.2">Section 2.1.2</a> for
additional details.
</p>
<p>
To get a header like
Public-Key-Pins-Report-Only: max-age=2592000;
pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="
Use
HpkpHeaderWriter hpkpHeaderWriter = new HpkpHeaderWriter();
hpkpHeaderWriter.setMaxAgeInSeconds(TimeUnit.DAYS.toSeconds(30));
</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>maxAgeInSeconds</code> - the maximum amount of time (in seconds) to regard the host
as a known pinned host. (i.e. TimeUnit.DAYS.toSeconds(30) would set this to 30
days)</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if maxAgeInSeconds is negative</dd>
</dl>
</li>
</ul>
<a id="setIncludeSubDomains(boolean)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>setIncludeSubDomains</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;setIncludeSubDomains&#8203;(boolean&nbsp;includeSubDomains)</pre>
<div class="block"><p>
If true, the pinning policy applies to this pinned host as well as any subdomains
of the host's domain name. The default is false.
</p>
<p>
See <a href="https://tools.ietf.org/html/rfc7469#section-2.1.3">Section 2.1.3</a>
for additional details.
</p>
<p>
To get a header like
Public-Key-Pins-Report-Only: max-age=5184000;
pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="; includeSubDomains
you should set this to true.
</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>includeSubDomains</code> - true to include subdomains, else false</dd>
</dl>
</li>
</ul>
<a id="setReportOnly(boolean)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>setReportOnly</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;setReportOnly&#8203;(boolean&nbsp;reportOnly)</pre>
<div class="block"><p>
To get a Public-Key-Pins header you should set this to false, otherwise the header
will be Public-Key-Pins-Report-Only. When in report-only mode, the browser should
not terminate the connection with the server. By default this is true.
</p>
<p>
See <a href="https://tools.ietf.org/html/rfc7469#section-2.1">Section 2.1</a> for
additional details.
</p>
<p>
To get a header like
Public-Key-Pins: max-age=5184000;
pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=";
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="
you should the this to false.
</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>reportOnly</code> - true to report only, else false</dd>
</dl>
</li>
</ul>
<a id="setReportUri(java.net.URI)">

</a>
<ul class="blockList">
<li class="blockList">
<h4>setReportUri</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;setReportUri&#8203;(java.net.URI&nbsp;reportUri)</pre>
<div class="block"><p>
Sets the URI to which the browser should report pin validation failures.
</p>
<p>
See <a href="https://tools.ietf.org/html/rfc7469#section-2.1.4">Section 2.1.4</a>
for additional details.
</p>
<p>
To get a header like
Public-Key-Pins-Report-Only: max-age=5184000;
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
report-uri="https://other.example.net/pkp-report"
Use
HpkpHeaderWriter hpkpHeaderWriter = new HpkpHeaderWriter();
hpkpHeaderWriter.setReportUri(new URI("https://other.example.net/pkp-report"));
</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>reportUri</code> - the URI where the browser should send the report to.</dd>
</dl>
</li>
</ul>
<a id="setReportUri(java.lang.String)">

</a>
<ul class="blockListLast">
<li class="blockList">
<h4>setReportUri</h4>
<pre class="methodSignature">public&nbsp;void&nbsp;setReportUri&#8203;(java.lang.String&nbsp;reportUri)</pre>
<div class="block"><p>
Sets the URI to which the browser should report pin validation failures.
</p>
<p>
See <a href="https://tools.ietf.org/html/rfc7469#section-2.1.4">Section 2.1.4</a>
for additional details.
</p>
<p>
To get a header like
Public-Key-Pins-Report-Only: max-age=5184000;
pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=";
pin-sha256="LPJNul+wow4m6DsqxbninhsWHlwfp0JecwQzYpOLmCQ=";
report-uri="https://other.example.net/pkp-report"
Use
HpkpHeaderWriter hpkpHeaderWriter = new HpkpHeaderWriter();
hpkpHeaderWriter.setReportUri("https://other.example.net/pkp-report");
</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>reportUri</code> - the URI where the browser should send the report to.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the reportUri is not a valid URI</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
</div>
</main>

<footer role="contentinfo">
<nav role="navigation">

<div class="bottomNav"><a id="navbar.bottom">

</a>
<div class="skipNav"><a href="HpkpHeaderWriter.html#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">

</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="HpkpHeaderWriter.html#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="HpkpHeaderWriter.html#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="HpkpHeaderWriter.html#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="HpkpHeaderWriter.html#method.detail">Method</a></li>
</ul>
</div>
<a id="skip.navbar.bottom">

</a></div>

</nav>
</footer>
<script>if (window.parent == window) {(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-2728886-23', 'auto', {'siteSpeedSampleRate': 100});ga('send', 'pageview');}</script><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v652eace1692a40cfa3763df669d7439c1639079717194" integrity="sha512-Gi7xpJR8tSkrpF7aordPZQlW2DLtzUlZcumS8dMQjwDHEnw9I7ZLyiOj/6tZStRBGtGgN6ceN6cMH8z7etPGlw==" data-cf-beacon='{"rayId":"7040df7f2f5f97cf","token":"bffcb8a918ae4755926f76178bfbd26b","version":"2021.12.0","si":100}' crossorigin="anonymous"></script>
</body>
</html>
